package com.jic.order.impl;

import com.jic.common.base.vo.Page;
import com.jic.order.mapper.OrderRouteSplitWarehouseConditionMapper;
import com.jic.order.request.OrderRouteSplitWarehouseConditionRequest;
import com.jic.order.response.OrderRouteSplitWarehouseConditionResponse;
import com.jic.common.base.vo.PageResult;
import com.jic.order.service.OrderRouteSplitWarehouseConditionService;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * 路由分仓规则匹配条件表
 * @author : 
 * @email : 
 * @since : 2020-03-04 01:44:18
 * @version : v1.0.0
 */
@Service
public class OrderRouteSplitWarehouseConditionServiceImpl implements OrderRouteSplitWarehouseConditionService {

    @Autowired
    private OrderRouteSplitWarehouseConditionMapper orderRouteSplitWarehouseConditionMapper;

    @Override
    public long insert(OrderRouteSplitWarehouseConditionRequest orderRouteSplitWarehouseCondition) {
        long flag = orderRouteSplitWarehouseConditionMapper.insert(orderRouteSplitWarehouseCondition);
        return flag;
    }

    @Override
    public long delete(Long id) {
        return orderRouteSplitWarehouseConditionMapper.delete(id);
    }

    @Override
    public long update(OrderRouteSplitWarehouseConditionRequest orderRouteSplitWarehouseCondition) {
        return orderRouteSplitWarehouseConditionMapper.update(orderRouteSplitWarehouseCondition);
    }

    @Override
    public OrderRouteSplitWarehouseConditionResponse queryByPrimaryKey(Long id){
        return orderRouteSplitWarehouseConditionMapper.queryByPrimaryKey(id);
    }

    @Override
    public List<OrderRouteSplitWarehouseConditionResponse> query(OrderRouteSplitWarehouseConditionRequest orderRouteSplitWarehouseCondition){
        return orderRouteSplitWarehouseConditionMapper.query(orderRouteSplitWarehouseCondition);
    }

    @Override
    public PageResult<OrderRouteSplitWarehouseConditionResponse> queryPage(OrderRouteSplitWarehouseConditionRequest orderRouteSplitWarehouseCondition, Page pageQuery) {
        //计算下标
        int startIndex = (pageQuery.getStart() - 1) * pageQuery.getLimit();
        List<OrderRouteSplitWarehouseConditionResponse> list = orderRouteSplitWarehouseConditionMapper.queryPage(startIndex, pageQuery.getLimit(), orderRouteSplitWarehouseCondition);
        long count = orderRouteSplitWarehouseConditionMapper.queryPageCount(orderRouteSplitWarehouseCondition);
        PageResult pageResult = new PageResult();
        pageResult.setRows(list);
        pageResult.setTotal(count);
        return pageResult;
    }


}